package com.mycompany.j2eem.service.wrjservice;

import me.xiaosheng.word2vec.Word2Vec;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.io.IOException;

/**
 * @author wurj
 * @time 2019/5/15 22:23
 * @description
 */
@Service
public class ModelService {
    public static Word2Vec word2Vec=null;

   // @PostConstruct
    public void init(){
        word2Vec=new Word2Vec();
        try {
            word2Vec.loadGoogleModel("./jar/word2vec.bin");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public float rebackParam(String a,String b){
        Word2Vec word2Vec=this.getWord2Vec();
        return word2Vec.wordSimilarity(a,b);
    }

    public Word2Vec getWord2Vec(){
        return this.word2Vec;
    }
}
